home *** CD-ROM | disk | FTP | other *** search
- /***********************************************************************\
- | Purpose :: This module is responsible for channeling menu commands |
- | to the correct routine. |
- |-----------------------------------------------------------------------|
- | Copyright © Joe Pillera, 1990. All Rights Reserved. |
- \***********************************************************************/
-
- #include "demo.h"
-
- /***********************************************************************\
- | void Do_Command( menuSelection ) |
- |-----------------------------------------------------------------------|
- | Purpose :: This routine processes "raw" mouse-down events generated |
- | by the user, an decides what action should then be taken. |
- |-----------------------------------------------------------------------|
- | Arguments :: |
- | menuSelection -> A longint, containing the menu bar (high byte) and |
- | menu item (low byte) of the menu hit event. |
- |-----------------------------------------------------------------------|
- | Returns :: void. |
- \***********************************************************************/
-
- void Do_Command (menuSelection)
- long menuSelection;
- {
- int menuID, menuItem; /* The extracted stuff from the longint */
-
- menuID = HiWord (menuSelection);
- menuItem = LoWord (menuSelection);
-
- switch (menuID) {
- case AppleID:
- Do_Apple_Cmd (menuItem);
- break;
- case FileID:
- Do_File_Cmd (menuItem);
- break;
- case EditID:
- break;
- }
- HiliteMenu (0);
- }
-
-
- /***********************************************************************\
- | void Do_Apple_Cmd( menuItem ) |
- |-----------------------------------------------------------------------|
- | Purpose :: The user clicked in the Apple menu, so decide whether to |
- | show the program "About..." box or launch a desk acc. |
- |-----------------------------------------------------------------------|
- | Arguments :: |
- | menuItem -> An integer showing which menu item was selected. |
- |-----------------------------------------------------------------------|
- | Returns :: void. |
- \***********************************************************************/
-
- static void Do_Apple_Cmd (menuItem)
- int menuItem;
- {
- DialogPtr thePtr; /* Pointer to the about box */
- GrafPtr savePort; /* Good habit: save old grafport */
- Str255 DAName; /* The desk accessory to launch */
- int whatHit; /* Trap for 'ok' and exit */
- Boolean done; /* Exit flag */
-
- /* If it's not the about box, open the DA */
- if (menuItem != AboutItem){
- GetItem (GetMHandle (AppleID), menuItem, DAName);
- OpenDeskAcc (DAName);
- }
- else {
- GetPort(&savePort);
- thePtr = GetNewDialog(About_Window, NIL, FRONT);
- Center_Window(thePtr,0,FALSE);
- ShowWindow(thePtr);
- SetPort(thePtr);
- Bold_Button(thePtr,OK_Button);
- ModalDialog(NIL,&whatHit);
- DisposDialog(thePtr);
- SetPort(savePort);
- }
- }
-
-
- /***********************************************************************\
- | void Do_File_Cmd( menuItem ) |
- |-----------------------------------------------------------------------|
- | Purpose :: The user clicked in the File menu, so decide what he chose |
- | and take appropriate action. |
- |-----------------------------------------------------------------------|
- | Arguments :: |
- | menuItem -> An integer showing which menu item was selected. |
- |-----------------------------------------------------------------------|
- | Returns :: void. |
- \***********************************************************************/
-
- static void Do_File_Cmd (menuItem)
- int menuItem;
- {
- long ticks;
- Handle h;
- ProcPtr pp;
-
- switch (menuItem) {
- case HelpItem:
- /* Enter the code resource here! */
- h = GetResource('HELP',128);
- if((ResErr == noErr) && (h != NIL)) {
- HLock(h);
- pp = (ProcPtr) *h;
- (*pp)();
- HUnlock(h);
- ReleaseResource(h);
- }
- else
- SysBeep(1);
- break;
- case QuitItem:
- program_done = TRUE;
- Delay(8,&ticks);
- FlashMenuBar(FileID);
- break;
- }
- }
-
-